import axios from "axios";
import { ref } from "vue";
let token = localStorage.getItem("token");

const service = axios.create({
  baseURL: process.env.VUE_APP_URL, //请求前缀
  timeout: "1000*6",
  headers: {
    authorization: token,
  },
});

//封装service
//请求拦截器
service.interceptors.request.use(
  //传回配置数据
  (config) => {
    return config;
  },
  (err) => {
    Promise.reject(err);
  }
);
//响应拦截器
service.interceptors.response.use(
  (response) => {
    console.log(response);
    return response;
  },
  (err) => {
    Promise.reject(err);
  }
);

export { service };
